const express = require('express');
const router = express.Router();
const pool = require('../database/db'); // 数据库连接池
const ArticleController = require('../controller/ArticleController');

// 初始化控制器
const articleController = new ArticleController(pool);

// 获取收购公告列表
router.get('/all', (req, res) =>  articleController.getAllArticles(req, res));
router.get('/dealer', (req, res) =>  articleController.getDealerArticles(req, res));
router.get('/gov', (req, res) =>  articleController.getGovArticles(req, res));
router.get('/', (req, res) => articleController.getArticles(req, res));
router.get('/search', (req, res) => articleController.searchArticles(req, res));
// 通过ID获取单个公告详情
router.get('/id', (req, res) => articleController.getArticleById(req, res));
// 发布收购公告
router.post('/', (req, res) => articleController.createArticle(req, res));

// 修改收购公告（仅更新 deadline）
router.put('/', (req, res) => articleController.updateArticle(req, res));




module.exports = router;
